package com.noyes4j.ota.service.impl;

import com.noyes4j.common.core.text.Convert;
import com.noyes4j.common.utils.DateUtils;
import com.noyes4j.ota.domain.SysFirmware;
import com.noyes4j.ota.mapper.SysFirmwareMapper;
import com.noyes4j.ota.service.ISysFirmwareService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName SysFirmwareServiceImpl
 * @Description: TODO
 * @Author zhaoweiqin
 * @Date 2021/1/29
 * @Version V1.0
 **/
@Service
public class SysFirmwareServiceImpl implements ISysFirmwareService {

    @Autowired
    private SysFirmwareMapper sysFirmwareMapper;

    /**
     * 查询固件
     *
     * @param id 固件ID
     * @return 固件
     */
    @Override
    public SysFirmware selectSysFirmwareById(Long id)
    {
        return sysFirmwareMapper.selectSysFirmwareById(id);
    }

    /**
     * 查询固件列表
     *
     * @param sysFirmware 固件
     * @return 固件
     */
    @Override
    public List<SysFirmware> selectSysFirmwareList(SysFirmware sysFirmware)
    {
        return sysFirmwareMapper.selectSysFirmwareList(sysFirmware);
    }

    /**
     * 新增固件
     *
     * @param sysFirmware 固件
     * @return 结果
     */
    @Override
    public int insertSysFirmware(SysFirmware sysFirmware)
    {
        sysFirmware.setCreateTime(DateUtils.getNowDate());
        return sysFirmwareMapper.insertSysFirmware(sysFirmware);
    }

    /**
     * 修改固件
     *
     * @param sysFirmware 固件
     * @return 结果
     */
    @Override
    public int updateSysFirmware(SysFirmware sysFirmware)
    {
        sysFirmware.setUpdateTime(DateUtils.getNowDate());
        return sysFirmwareMapper.updateSysFirmware(sysFirmware);
    }

    /**
     * 删除固件对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteSysFirmwareByIds(String ids)
    {
        return sysFirmwareMapper.deleteSysFirmwareByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除固件信息
     *
     * @param id 固件ID
     * @return 结果
     */
    @Override
    public int deleteSysFirmwareById(Long id)
    {
        return sysFirmwareMapper.deleteSysFirmwareById(id);
    }

}
